<%@ page language="java" import="java.util.*,com.king.cms.common.*" pageEncoding="UTF-8"%>
<%@ include file="/hotel/include/css.jsp"%><%-- /*包含css样式表*/ --%> 
<%
   String type = request.getParameter("type");
   String title = "会议地点";
   if(null != type){
      if("0".equals(type)){
         title = title;
      }
      if("1".equals(type)||"2".equals(type)){
         title = "播放地点";
      }
      
   }
    
   String ctype = (String)request.getAttribute("ctype");
   List fivearea = (List)request.getAttribute("dataList");
   StringBuffer singleIdStr = new StringBuffer();
   StringBuffer mixIdStr = new StringBuffer();
 %> 

<html>
<head>
<title>信息发布系统-<%=title%></title>
<script language="javaScript">
function changeview(){ 

     var single = '<%=Constants.SINGLE_SCREEN%>'; 
     var objec = document.getElementsByName('client_type'); 
     var str = '';
    
     for(var k = 0;k<objec.length;k++){
          if(objec[k].checked){
             str = objec[k].value;
             break;
           }
     } 
      
       var idstr = form1.mixStr.value; 
       var oo = idstr.split('#');
       for(var i = 0;i<oo.length;i++){
           var obj = document.getElementById('lcd_'+oo[i]);  
            if(obj != null){ 
             	if(str == single) 
                 	obj.disabled = true;
                   
              }
          }
       var idStr1 = form1.singleStr.value;  
       var dd = idStr1.split('#');
       for(var i = 0;i<dd.length;i++){
           var obj = document.getElementById('lcd_'+dd[i]);  
            if(obj != null){  
                 	obj.disabled = false;
                  
              }
          }
    

} 
function changeview1(){ 
      
     var mix = '<%=Constants.MIX_SCREEN%>'; 
     var objec = document.getElementsByName('client_type'); 
     var str = '';
     
     for(var k = 0;k<objec.length;k++){
          if(objec[k].checked){
             str = objec[k].value;
             break;
           }
     }  
       var idStr = form1.singleStr.value;  
       var oo = idStr.split('#');
       for(var i = 0;i<oo.length;i++){
           var obj = document.getElementById('lcd_'+oo[i]);  
            if(obj != null){ 
             	if(str == mix) 
                 	obj.disabled = true;
                  
              }
          }
        var idstr = form1.mixStr.value; 
        var ww = idstr.split('#');
        for(var i = 0;i<ww.length;i++){
           var obj = document.getElementById('lcd_'+ww[i]);  
            if(obj != null){  
                 	obj.disabled = false; 
              }
          } 
    

} 
function selectRoom(){
	var nameStr = '';
    var idStr = '';
    var contentStr = '';
    var lcdtype = '';
    
    var single = '<%=Constants.SINGLE_SCREEN%>';
    var mix = '<%=Constants.MIX_SCREEN%>';
    var str = '';
     var objec = document.getElementsByName('client_type');
     var flag = false;
     for(var k = 0;k<objec.length;k++){
          if(objec[k].checked){
             flag = true;
             break;
           }
     }
     if(!flag){
       alert('请选择LCD显示屏大类');
       return;
       }
     for(var j = 0;j<objec.length;j++){
        var type = '';
        if(objec[j].checked)
           type = objec[j].value;
        else
            continue;
	    if(type == null){
	      
	      break;
	    }else{
	       if(type == single){
	          lcdtype = '15';
	          str = form1.singleStr.value;
	          objs = str.split('#');
	          if(objs.length > 0){ 
		        for(var i = 0;i<objs.length-1;i++){
			    	 var temp = 'lcd_'+ objs[i]; 
			         var nameTemp = document.getElementById(temp); 
			         if(nameTemp.checked){
			            nameStr += document.getElementById('name_'+objs[i]).value;	
			            nameStr +=',';
			            idStr += objs[i]+',';
			            contentStr +='null#';
			          }
			     }
			   }
	       }
	        if(type == mix){
	          str = form1.mixStr.value; 
	          var objs = str.split('#');
	    		if(objs.length > 0){ 
		    	for(var i = 0;i<objs.length-1;i++){
		    	 var temp = 'lcd_'+ objs[i]; 
		         var nameTemp = document.getElementById(temp); 
		         		if(nameTemp.checked){
					            nameStr += document.getElementById('name_'+objs[i]).value;	
					            nameStr +=',';
					            idStr += objs[i]+','; 
					            var o = document.getElementsByName('lineCon_'+ objs[i]); 
					            var tt = "";
				                if(o.length>0){
				                   for(var k =0;k<o.length;k++){
				                       if(o[k].value != '')
				                          tt+=o[k].value+','; 
				                   }
				                } 
				                if(tt=='')
				                   tt = 'null';
				                contentStr +=tt+'#'; 
				                
					             
		     			  } 
		   			 }
		    
	   			 }
	   		  if(contentStr.indexOf(',') != -1)
	   		      lcdtype = '40';
	   		  else
	   		      lcdtype = '15';     
	       }
	    
	    }
	   
   } 
   opener.form1.fieldflag.value=lcdtype;
   opener.form1.hytzPortName.value=nameStr;
   opener.form1.hytzPort.value=idStr;
   opener.form1.content.value=contentStr;
   window.close();
   
}
function showDiv(lcdId){
   	  var str = 'tr_'+lcdId; 
      var obj = document.getElementById(str);  
      if(obj != null){ 
      	 if(obj.style.display=='')
      	    obj.style.display = 'none'; 
      	 else
             obj.style.display='';     
      }
   }
 
     function   addContent(id){       
        var obj = document.getElementById('div_'+id); 
        obj.insertAdjacentHTML('BeforeEnd','<br><input   type="text" class="area100" onblur="return docheck(this)" name="lineCon_'+id+'"   size=22>');   
           
      }
       
/*取得字符串的字节长度*/
function strlen(str)
{ var i;
  var len;
 len=0;
for(i=0;i<str.length;i++)
{
if(str.charCodeAt(i)>255)
  len+=2;
  else
  len++;
}
return len;
}   
function docheck(obj){
  var length = strlen(obj.value);
  if(length > 50)
     alert("只能输入25个汉字或50个字符");

} 
</script>
<head>
</head>
<body >
<form name="form1"   method="post" action=""> 
<center>
 <table border="0" align="center" cellpadding="4"    cellspacing="1" style="border-collapse: collapse;" bordercolor="#111111"   width="98%"   >
 
  <tr align="center">
    <td class="top_td" align="left" colspan=2> <b>终端LCD选择</b> </td>
  </tr>  
     
    <tr id="fivearea"   valign="top">
    <td class="td2"   width="65%" align="center"><img src="<%=path %>/img/fivearea_r1_c1.jpg" align="left"></td>
    <td >
    <table algin="left" valign="top"> 
       
      <%if(fivearea != null && fivearea.size() > 0){%>
      
      
      <tr>
        <td> <b><input type="radio" name="client_type" onclick="changeview()" value="<%=Constants.SINGLE_SCREEN%>" <%if(Constants.SINGLE_SCREEN.equals(ctype)){out.print(" checked");} %>>&nbsp;单屏LCD</b> </td> 
       </tr> 
      <%
           for(int i = 0;i<fivearea.size();i++){
                 Map m = (Map)fivearea.get(i);
                 String id = m.get("ID")+"";
                 String clientType = m.get("CLIENT_TYPE")+"";
                 if(!Constants.SINGLE_SCREEN.equals(clientType))
                    continue;
                 singleIdStr.append(id).append("#"); 
       %>
       <tr>
       
        <td nowrap>
        <input type="checkbox" value="<%=id%>" name="lcd_<%=id%>"    <%if(m.get("isSelect")!=null  ){out.print("checked");} %> ><b><%=m.get("CLIENT_NAME") %>
            (<%=m.get("CLIENT_ADDRESS") %>)</b> 
        	
        	 
        	<input type="hidden" name="name_<%=id%>" value="<%=m.get("CLIENT_NAME") %>">
        	 
        	</td> 
      </tr> 
       
      <%}} %>
       
      <%if(fivearea != null && fivearea.size() > 0){%>
      
      <tr>
        <td> <b><input type="radio" name="client_type"  onclick="changeview1()" value="<%=Constants.MIX_SCREEN%>" <%if(Constants.MIX_SCREEN.equals(ctype)){out.print(" checked");} %>>&nbsp;混合屏LCD</b></td> 
       </tr> 
      
      <%
           for(int i = 0;i<fivearea.size();i++){
                 Map m = (Map)fivearea.get(i);
                 String id = m.get("ID")+""; 
                 
                 String clientType = m.get("CLIENT_TYPE")+"";
                 if(!Constants.MIX_SCREEN.equals(clientType))
                    continue;
                    mixIdStr.append(id).append("#");
       %>
       <tr>
        <td nowrap>
        <table align="center">
        <tr>
        <td width="80%" algin="left" >
        <input type="checkbox" value="<%=id%>"   name="lcd_<%=id%>"   <%if(m.get("isSelect")!=null  ){out.print("checked");} %> > <b><%=m.get("CLIENT_NAME") %>
            (<%=m.get("CLIENT_ADDRESS") %>)</b>
        	<%if(Constants.MIX_SCREEN.equals(clientType)){ %> </td><Td>&nbsp;&nbsp;&nbsp;&nbsp;<!-- <input type="button" value="添加" class="area100" onclick="addContent('')" >-->&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%} %>
        	 
        	 </td>
        	 <tr>
        	 <td colspan=2>
	        	<input type="hidden" name="name_<%=id%>" value="<%=m.get("CLIENT_NAME") %>">
	        	<div id="div_<%=id%>">
	        		 <%if(Constants.MIX_SCREEN.equals(clientType)){
	        	      List l = (List)m.get(id);
	        	      if(null != l){
	        	         for(int j = 0;j<l.size();j++){
	        	           Map data = (Map)l.get(j);
	        	           out.println("<input   type=\"text\" class=\"area100\" onblur=\"return docheck(this)\" name=\"lineCon_"+id+"\" value="+data.get("LCD_CONTENT")+"   size=18>");
	        	           out.println("<br>");
	        	         }
	        	      }
	        	     } %>
	        	 </div>
        	 	</td>
        	 <tr>
        	 </table>
        	 
        	</td> 
      </tr> 
       
      <%}}%>
       
    </table>
    </td>
  </tr> 
  <tr>
    <td   colspan="2" align="right">
    	 <input type="hidden" name="singleStr" value="<%=singleIdStr%>">
    	 <input type="hidden" name="mixStr" value="<%=mixIdStr%>">
    <input type="button" value="确定" class="area100" onclick="javaScript:selectRoom();">&nbsp;&nbsp;
    <input type="button" value="关闭" class="area100" onclick="javaScript:window.close();">
    </td>
  </tr>
 
</table> 
</center>
 
</form> 
</body>
</html>

 